package com.haoqi.document.template.base;

import com.haoqi.document.template.base.constants.CommonConstants;

public class IBaseResultUtils {

    public static IBaseResult success() {
        return success("");
    }

    public static IBaseResult success(Object obj) {
        return success(obj, CommonConstants.DEFAULT_SUCCESS_MSG);
    }

    public static IBaseResult success(Object obj, String msg) {
        IBaseResult<Object> result = new IBaseResult<>();
        result.setCode(CommonConstants.DEFAULT_SUCCESS_CODE);
        result.setMsg(msg);
        result.setData(obj);
        return result;
    }

    public static IBaseResult error(String msg) {
        return error(CommonConstants.DEFAULT_ERROR_CODE, msg);
    }

    public static IBaseResult error(Integer code, String msg) {
        IBaseResult<Object> result = new IBaseResult<>();
        result.setCode(code != null ? code : -1);
        result.setMsg(msg);
        result.setData("");
        return result;
    }
}